package com.utils.score;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class LocalDatabase extends SQLiteOpenHelper {

	
	private static final String TABLE_SCORES = "table_scores";
	private static final String COL_ID = "ID";
	private static final String COL_NAME = "NAME";
	private static final String COL_SCORE = "SCORE";
 
	private static final String CREATE_BDD = "CREATE TABLE " + TABLE_SCORES + " ("
	+ COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_NAME + " TEXT NOT NULL, " + COL_SCORE + " INTEGER NOT NULL);";
	
	public LocalDatabase(Context context, String name, CursorFactory factory, int version) {
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(CREATE_BDD);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE " + TABLE_SCORES + ";");
		onCreate(db);
	}
}
